<?php 
include TMPL_PATH.'public/header.phtml';
?>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <a href='javascript:;' class="on"><em>友情链接列表</em></a><span>|</span>
        <a href="javascript:add();">添加友情链接</a>
    </div>
</div>
<div class="pad_10">
<form name="myform" id="myform" action="<?php echo U('site/public_link_listorder')?>" method="post" >
<div class="table-list">
<table width="100%" cellspacing="0">
	<thead>
		<tr>
			<th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('linkids[]');"></th>
			<th width="35" align="center">排序</th>
			<th>网站名称</th>
			<th width="15%" align="center">图片LOGO</th>
			<th width='10%' align="center">链接类型</th>
			<th width="10%" align="center">推荐</th>
			<th width="10%" align="center">状 态</th>
			<th width="15%" align="center">管理操作</th>
		</tr>
	</thead>
<tbody>
<?php 
if(isset($linkList) && $linkList):
	foreach ($linkList as $link):
?>
	<tr>
		<td align="center"><input type="checkbox" name="linkids[]" value="<?php echo $link['id'];?>"></td>
		<td align="center"><input id="listorder-<?php echo $link['id']?>" name='listorders[<?php echo $link['id']?>]' type='text' size='3' title="当光标离开输入框后修改排序" value='<?php echo $link['listorder']?>' onblur="javascript:setting_listorder(<?php echo $link['id']?>);" class='input-text-c'></td>
		<td><a href="<?php echo $link['url'];?>" title="前往网站" target="_blank"><?php echo $link['name'];?></a> </td>
		<td align="center" width="12%">
		<?php if($link['logo']):?><img src="<?php echo $link['logo'];?>" width=83 height=31>
		<?php else:?>&nbsp;<?php endif;?>
		</td>
		<td align="center" width="10%"><?php echo $link['linktype']==1 ? 'LOGO' : '文字';?>链接</td>
		<td align="center"><?php if($link['istop']==1){?><font color="red">√</font><?php }else{?><font color="blue">×</font><?php }?></td>
		<td align="center"><?php if($link['disabled']==1){?><font color="red">√</font><?php }else{?><font color="blue">×</font><?php }?></td>
		<td align="center" width="12%"><a href="javascript:;"
			onclick="edit(<?php echo $link['id'];?>, '<?php echo $link['name'];?>')"
			title="修改">修改</a> |  <a
			href='<?php echo U('site/link_delete', 'linkid='. $link['id']);?>'
			onClick="return confirm('确认要删除 『 <?php echo $link['name'];?> 』 吗？')">删除</a> 
		</td>
	</tr>
<?php 
	endforeach;
endif;
?>
	</tbody>
</table>
</div>
<div class="btn"> 
<input type="submit" class="button" name="dosubmit" onClick="document.myform.action='<?php echo U('site/link_delete');?>'" value="删除"/></div>
<div id="pages"><?php echo $pageShow;?></div>
</form>
</div>
</body>
<script type="text/javascript">
<!--
function setting_listorder(id){
	var lisobj = $('#listorder-'+id);
	listorder = parseInt(lisobj.val());
	if(isNaN(listorder)){
		alert('排序只能设置为整数.');return;
	}
	$.get('<?php echo U('site/change_link_listorder_ajax');?>&linkid='+id+'&listorder='+listorder,function(data){
		if(data==1){lisobj.val(listorder)}
	});
}
function add(){
	window.top.art.dialog({id:'add',iframe:'<?php echo U('site/link_add')?>', title:'添加友情链接', width:'700', height:'450'}, function(){var d = window.top.art.dialog({id:'add'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'add'}).close()});void(0);
}
function edit(id, name) {
	window.top.art.dialog({id:'edit'}).close();
	window.top.art.dialog({title:'编辑 '+name+' ',id:'edit',iframe:'<?php echo U('site/link_edit');?>&linkid='+id,width:'700',height:'450'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
//-->
</script>
</html>